<%@ page import="jakarta.servlet.http.Cookie" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/29 0029
  Time: 14:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--    application.removeAttribute("count");--%>
<%--    Integer requestCount=(Integer) request.getAttribute("count");--%>
<%--    if(requestCount==null){--%>
<%--        requestCount=1;--%>
<%--    }else{--%>
<%--        requestCount++;--%>
<%--    }request.setAttribute("count",requestCount);--%>

<%--    Integer sessionCount=(Integer) request.getSession().getAttribute("count");--%>
<%--    if(sessionCount==null){--%>
<%--        sessionCount=1;--%>
<%--    }else{--%>
<%--        sessionCount++;--%>
<%--    }request.getSession().setAttribute("count",sessionCount);--%>

<%--    Integer appliCationCount=(Integer) application.getAttribute("count");--%>
<%--    if(appliCationCount==null){--%>
<%--        appliCationCount=1;--%>
<%--    }else{--%>
<%--        appliCationCount++;--%>
<%--    }application.setAttribute("count",appliCationCount);--%>

<%--    out.print("request计数:"+request.getAttribute("count"));%><br/><%--%>
<%--    out.print("session计数:"+request.getSession().getAttribute("count"));%><br/><%--%>
<%--    out.print("application计数:"+application.getAttribute("count"));%><br/><%--%>


<%
    Cookie cookie=new Cookie("count","1");
    cookie.setMaxAge(600);
    cookie.setValue("2");
    response.addCookie(cookie);

    Cookie[] cookies=request.getCookies();
    for(Cookie c:cookies){
        out.print("key:"+c.getName());%><br/><%
        out.print("value:"+c.getValue());%><br/><br/><%
    }
%>
</body>
</html>
